package link.config;

import android.support.annotation.Nullable;
import java.util.ArrayList;
import link.model.AgentInfoVo;
import link.model.ConfigInfoVo;
import org.an.ku.util.ACache;
import org.an.proj.contacts.MyApplication;

/**
 * Created by an on 2016/12/18.<br/>
 */

public class AgentConfig {
  private static final String CONFIG_NAME = "AgentConfig";
  private static final String KEY_CONFIGINFO = "agentInfo";

  private static AgentConfig mInstance;
  private ACache mACache;

  private AgentConfig() {
    mACache = ACache.get(MyApplication.getInstance(), CONFIG_NAME);
  }

  public static AgentConfig getInstance() {
    if (mInstance == null) {
      synchronized (AgentConfig.class) {
        if (mInstance == null) {
          mInstance = new AgentConfig();
        }
      }
    }
    return mInstance;
  }

  public void setAgentInfo(@Nullable AgentInfoVo agentInfoVo) {
    if (agentInfoVo != null) {
      mACache.put(KEY_CONFIGINFO, agentInfoVo);
    }
  }

  @Nullable public AgentInfoVo getAgentInfo() {
    return (AgentInfoVo) mACache.getAsObject(KEY_CONFIGINFO);
  }
}
